var form;
var selectArr;
$(function () {
    form = $('#xh_form');
    getType();

    function getType() {
        $.ajax({
            url:baseUrl+'device/getTabletsData',
            method:'post',
            dataType:'json',
            success:function (data) {
                fillSelect('prod',data);
            }
        });
    }

    function fillSelect(selector,data,id,text) {
        var str = '<option value="" style="display: none" selected>请选择</option>';
        if(id != null && text != null){
            $.each(data,function (key,val) {
                str += '<option value="'+val[id]+'">'+val[text]+'</option>';
            })
        } else {
            $.each(data,function (key,val) {
                str += '<option value="'+key+'">'+val+'</option>';
            })
        }
        $('#'+selector).empty().append(str);
    }

    form.on('click','#save',function () {
        new xhForm(form).submit(baseUrl + 'device/saveProjectData',{},function (res) {
            if(res.code === 200){
                window.top.swal('成功',res.msg,'success');
                window.top.xhTop.closeModal();
            }
        });
    });
});
